package org.tloss.web.editor.utils;

import java.net.URL;
import java.util.Properties;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.internal.util.BundleUtility;
import org.osgi.framework.Bundle;
import org.tloss.web.editor.Activator;

@SuppressWarnings("restriction")
public class Constants {
	public static class CodeType {
		public static final int SQL = 0;
		public static final int JAVA = 1;
	}

	public static final Object[] EMPTY_ARRAY = new Object[] {};
	public static Image DATABASE_IMAGE;
	public static Image TABLE_IMAGE;
	public static Image PARAM_IMAGE;
	public static Image BOOLEAN_IMAGE;
	public static Image VARIABLE_IMAGE;

	public static String CONFIGURATION_FOLDER = "config";
	public static String CONFIGURATION_EXT = "cmpe";
	public static String ENTITY_FOLDER = "entities";
	public static String ENTITY_EXT = "empe";
	public static String SQL_EXT = "sqlmpe";
	public static String JAVA_EXT = "java";
	public static String SQL_FOLDER = "sql";
	public static String DATABASE_FOLDER = "database";
	public static String DATABASE_EXT = "dmpe";
	public static String FORMS_FOLDER = "forms";
	public static String FORMS_EXT = "fmpe";
	public static String MESSAGES_FOLDER = "messages";

	public static String CONFIGURATION_SAMPLE_FILE = "config.cmpe";
	public static String MESSAGES_SAMPLE_FILE = "messages.mmpe";
	public static String ENTITY_SAMPLE_FILE = "entities.empe";
	public static String SQL_SAMPLE_FILE = "sql.sqlmpe";
	public static String DATABASE_SAMPLE_FILE = "database.dmpe";
	public static String FORMS_SAMPLE_FILE = "forms.fmpe";

	public static String CONFIG_FILE = "config/config.cmpe";

	public static String FORM_TEMPLATE = "/templates/forms.vm";
	public static String FORM__VIEWTEMPLATE = "/templates/formview.vm";
	public static String FORM_VIEWMAPPING_TEMPLATE = "/templates/viewMapping.vm";
	public static String SELECT_SQL_VELOCITY_TEMPLATE = "/templates/sql_select.vm";
	public static String DELETE_SQL_VELOCITY_TEMPLATE = "/templates/sql_delete.vm";
	public static String INSERT_SQL_VELOCITY_TEMPLATE = "/templates/sql_insert.vm";
	public static String UPDATE_SQL_VELOCITY_TEMPLATE = "/templates/sql_update.vm";
	public static String SPRING_JDBC_TEMPLATE = "/templates/spring_jdbc.vm";

	public static String VIEWMAPPING_FILE = "viewMapping.xml";

	public static final String SQL_SELECT_MODE = "Select";
	public static final String SQL_INSERT_MODE = "Insert";
	public static final String SQL_UPDATE_MODE = "Update";
	public static final String SQL_DELETE_MODE = "Delete";

	public static final byte[] EMPTY_BYTES = new byte[] {};

	public static String SRC_FOLDER = "src";
	public static String SRC_FOLDER_PRO = "SRC_FOLDER";
	public static String BEANFACTORY_PRO = "BEANFACTORY";
	public static String CONVERTOR_PRO = "CONVERTOR";
	

	public static String SRC_RESOURCE_FOLDER = "src";
	public static String SRC_RESOURCE_FOLDER_PRO = "SRC_RESOURCE_FOLDER_PRO";

	public static ImageDescriptor FIELD_DESCRIPTOR;
	public static ImageDescriptor RUNSCRIPT_DESCRIPTOR;
	public static ImageDescriptor COLUMN_DESCRIPTOR;

	public static Properties DEFAULT_CONFIG = new Properties();

	static {
		Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
		URL fullPathString = BundleUtility.find(bundle, "icons/database.gif");
		DATABASE_IMAGE = ImageDescriptor.createFromURL(fullPathString)
				.createImage();

		fullPathString = BundleUtility.find(bundle, "icons/tbl.gif");
		TABLE_IMAGE = ImageDescriptor.createFromURL(fullPathString)
				.createImage();

		fullPathString = BundleUtility.find(bundle, "icons/F.gif");
		FIELD_DESCRIPTOR = ImageDescriptor.createFromURL(fullPathString);

		fullPathString = BundleUtility.find(bundle, "icons/runscript.gif");
		RUNSCRIPT_DESCRIPTOR = ImageDescriptor.createFromURL(fullPathString);

		fullPathString = BundleUtility.find(bundle, "icons/param.gif");
		PARAM_IMAGE = ImageDescriptor.createFromURL(fullPathString)
				.createImage();

		fullPathString = BundleUtility.find(bundle, "icons/boolean.gif");
		BOOLEAN_IMAGE = ImageDescriptor.createFromURL(fullPathString)
				.createImage();

		fullPathString = BundleUtility.find(bundle, "icons/variable.gif");
		VARIABLE_IMAGE = ImageDescriptor.createFromURL(fullPathString)
				.createImage();

		fullPathString = BundleUtility.find(bundle, "icons/column.gif");
		COLUMN_DESCRIPTOR = ImageDescriptor.createFromURL(fullPathString);

		DEFAULT_CONFIG.setProperty(Constants.SRC_FOLDER_PRO,
				Constants.SRC_FOLDER);
		DEFAULT_CONFIG.setProperty(Constants.SRC_RESOURCE_FOLDER_PRO,
				Constants.SRC_RESOURCE_FOLDER);
		DEFAULT_CONFIG.setProperty(Constants.BEANFACTORY_PRO,
				"org.tloss.web.spring.BeanFactory");
		DEFAULT_CONFIG.setProperty(Constants.CONVERTOR_PRO,
		"org.tloss.web.Convertor");
		

	}
}
